package cn.mineserv.video.videoordersystem.utils;

import java.util.regex.Matcher;
import java.util.regex.Pattern;

/**
 * @author Y_YuanZhouLv
 */
public class CountText {
    String str;
    private static final String chineseCharacter = "[\\u4e00-\\u9fa5]";
    private static final String letter = "[a-zA-Z]";
    private static final String number = "\\d";
    public CountText(String str) {
        this.str = str;
    }

    public int countChinese() {
        int count = 0;
        Pattern pattern = Pattern.compile(chineseCharacter);
        Matcher m = pattern.matcher(str);
        while (m.find()) {
            count++;
        }

        pattern = Pattern.compile(letter);
        m = pattern.matcher(str);
        while (m.find()) {
            count++;
        }

        pattern = Pattern.compile(number);
        m = pattern.matcher(str);
        while (m.find()) {
            count++;
        }
        return count;
    }
}
